package cn.springcloud.fix.resource.handler;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.oauth2.provider.error.WebResponseExceptionTranslator;

/**
 * 替换掉 AbstractOAuth2SecurityExceptionHandler 的 exceptionTranslator，默认是 DefaultWebResponseExceptionTranslator
 */
public class MyWebResponseExceptionTranslator implements WebResponseExceptionTranslator<String> {

    @Override
    public ResponseEntity<String> translate(Exception e) throws Exception {
        // BaseResponse response = BaseResponse.builder().code(-1).message(e.getMessage()).build();
        return new ResponseEntity<>("dddd", HttpStatus.METHOD_NOT_ALLOWED);
    }
}
